package com.cc.secondKill.service.impl;

import com.cc.secondKill.dao.UserMapper;
import com.cc.secondKill.pojo.User;
import com.cc.secondKill.service.IUSerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service("userService")
public class UserService implements IUSerService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean insertUserInfo(User user) {
        User exitsUser = this.userMapper.findUserByPhoneNum(user.getPhone());
        if (exitsUser == null){
            user.setTime(new Date());
            Integer rowsCounts = userMapper.insert(user);
            return rowsCounts > 0;
        }
        return false;
    }
}
